<?php
/**
 * Created by PhpStorm.
 * User: skytop
 * Date: 16-8-31
 * Time: 下午5:10
 */

namespace Admin\Model;

use \Think\Model\RelationModel;
class BlogRelationModel extends RelationModel
{
    protected $tableName='blog';
    protected $_link=array(
        'attr'=>array(
            'mapping_type'=>self::MANY_TO_MANY,
            'mapping_name'=>'attr',
            'foreign_key'=>'bid',
            'relation_foreign_key'=>'aid',
            'relation_table'=>'hd_blog_attr'
        ),

        'cate'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'cid',
            'mapping_fields'=>'name',
            'as_fields'=>'name:cate'
        ),
    );

    protected $_validate=array(
        array('content','require','请填写内容'),
        array('cid','number','请选择博文分类'),
        array('title','require','请填写标题'),
        array('click','number','请填写点击次数'),
        array('title','','此博文标题已存在',0,'unique',1)
    );
}